/*
 * Created on Sep 22, 2003
 * Alerter
 * Local Projects Database
 * (c) 2003 eRomania Gateway Association
 *
 */
package ro.gateway.aida.usr.messaging;

import ro.gateway.aida.db.PersistentObject;



/**
 * @author Mihai Postelnicu
 * Alerter
 * Remember : this class defines user settings about alerts. It does not store
 * alert results.
 * The results of all the issued alerts are implemented by the Event
 * class.
 * Alerter is the basic root class for both filters and approvers
 *  *
 */
public class Alerter implements PersistentObject
{
      protected int matchedCount;
      protected int totalCount;
      protected long userId;
      protected boolean enabled;
      protected int priority;
      protected int alerterType;
      protected String purpose;
      protected String name;
      protected boolean mailable;//owner will receive it via email, too
      protected long id;
      protected boolean intersection;

      public static final int APPROVER_ALERT = 1;
      public static final int FILTER_ALERT = 2;

      public Alerter( long id, long userId )
      {
            matchedCount = 0;
            totalCount = 0;
            this.id = id;
            this.userId = userId;
            this.setEnabled( true );
            priority = Alert.PRIORITY_NORMAL;
            alerterType = FILTER_ALERT;
            intersection = false;
      }

      public void incMathed()
      {
            matchedCount++;
      }

      public void incTotal()
      {
            totalCount++;
      }

      /**
       * An alerter can be temporarily disabled
       * @return
       */
      public boolean isEnabled()
      {
            return enabled;
      }

      /**
       * An alerter can also issue email notifications
       * @return
       */
      public boolean isMailable()
      {
            return mailable;
      }

      /**
       * An alerter has an user_id as its owner
       * @return
       */
      public long getUserId()
      {
            return userId;
      }

      /**
       * An alerter can have 3 priorities:
       * - high : notifications are displayed with bold
       * - normal : notifications are displayed normally
       * - low : notifications are displayed optionally
       * these will generate alerts with the same priority
       * @return
       */
      public int getPriority()
      {
            return priority;
      }

      /**
       * An alerter will always be set with a purpose. Having many alerts
       * can sometimes confuse the user. We can write down here the purpose
       * of the alert. This is a field that is for personal use, so write
       * it in the desired language.
       * @return
       */
      public String getPurpose()
      {
            return purpose;
      }

      /**
       * The alerter can be a filter alerterType or an approver alerterType
       * @return
       */
      public int getAlerterType()
      {
            return alerterType;
      }

      /**
       * @param b
       */
      public void setEnabled( boolean b )
      {
            enabled = b;
      }

      /**
       * @param b
       */
      public void setMailable( boolean b )
      {
            mailable = b;
      }

      /**
       * @param i
       */
      public void setUserId( long i )
      {
            userId = i;
      }

      /**
       * @param i
       */
      public void setPriority( int i )
      {
            priority = i;
      }

      /**
       * @param string
       */
      public void setPurpose( String string )
      {
            purpose = string;
      }

      /**
       * @param i
       */
      public void setAlerterType( int i )
      {
            alerterType = i;
      }

      /**
       * @return
       */
      public long getId()
      {
            return id;
      }

      /**
       * @param i
       */
      public void setId( long i )
      {
            id = i;
      }

      /**
       * @return
       */
      public String getName()
      {
            return name;
      }

      /**
       * @param string
       */
      public void setName( String string )
      {
            name = string;
      }

      /**
       * @return
       */
      public int getMatchedCount()
      {
            return matchedCount;
      }

      /**
       * @param i
       */
      public void setMatchedCount( int i )
      {
            matchedCount = i;
      }

      /**
       * @return
       */
      public boolean isIntersection()
      {
            return intersection;
      }

      /**
       * @param b
       */
      public void setIntersection( boolean b )
      {
            intersection = b;
      }

      /**
       * @return
       */
      public int getTotalCount()
      {
            return totalCount;
      }

      /**
       * @param i
       */
      public void setTotalCount( int i )
      {
            totalCount = i;
      }

}
